//
//  KFCategoryModel.m
//  KafeeSale
//
//  Created by Liboom on 2025/6/9.
//

#import "KFCategoryModel.h"
@implementation KFCategoryModel

+ (NSDictionary *)mj_objectClassInArray {
    return @{
        @"goods": [KFProductModel class]
    };
}
@end
@implementation KFProductModel
+ (NSDictionary *)mj_replacedKeyFromPropertyName {
    return @{@"tid":@"id",@"desc":@"description"};
}
+ (NSDictionary *)mj_objectClassInArray {
    return @{@"cooksList": [KFDishCookList class],
             @"specList": [KFDishSpecList class]};
}
- (CGFloat)calculateCurrentPrice {
    CGFloat totalPrice = self.price; // 基础价格
    
    if (self.selectedSpecs.count > 0) {
        for (KFDishSpecList *spec in self.selectedSpecs) {
            totalPrice += spec.specPrice;
        }
    }
    
    // 累加做法价格
    if (self.selectedPractices.count > 0) {
        for (NSDictionary *practice in self.selectedPractices) {
            NSString *priceStr = practice[@"cookPrice"];
            if (priceStr && [priceStr respondsToSelector:@selector(floatValue)]) {
                totalPrice += [priceStr floatValue];
            }
        }
    }
    
    return totalPrice;
}
@end

@implementation KFDishCookList
+ (NSDictionary *)mj_replacedKeyFromPropertyName {
    return @{@"tid":@"id"};
}
@end

@implementation KFDishSpecList
+ (NSDictionary *)mj_replacedKeyFromPropertyName {
    return @{@"tid":@"id"};
}
@end
